package one.three.twentySeven;

public class Max {

	private static class Node<Item> {
		private Item item;
		private Node next;

		@Override
		public String toString() {
			return "[" + item + "]";
		}
	}

	public static int max(Node<Integer> n) {
		if (n != null) {
			int m = 0;
			Node<Integer> c = n;
			while (c != null) {
				if (c.item > m) {
					m = c.item;
				}
				c = c.next;
			}
		}
		return 0;
	}

	public static void main(String[] args) {
		Node<Integer> f = new Node<Integer>();
		f.item=0;
		Node<Integer> c = f;
		for (int i = 1; i <= 10; i++) {
			c.next = new Node<Integer>();
			c.next.item = i;
			c = c.next;
		}

		c = f;
		while (c != null) {
			System.out.println(c.item);
			c = c.next;
		}
		int max=max(f);
		System.out.println(max);
	}

}
